#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;

void duplicateZeros(vector<int>& arr) {
    int cur = 0, dest = -1;
    int n = arr.size();
    while (dest <= n - 2)
    {
        if (arr[cur] == 0)
        {
            dest += 2;
        }
        else
        {
            ++dest;
        }
        if (dest >= n - 1)
            break;
        ++cur;
    }

    if (dest >= n)
    {
        arr[n - 1] = 0;
        --cur;
        dest -= 2;
    }

    while (cur >= 0)
    {
        if (arr[cur] == 0)
        {
            arr[dest--] = 0;
            arr[dest--] = 0;
        }
        else
        {
            arr[dest--] = arr[cur];
        }
        --cur;
    }
}

//vector<int> singleNumber(vector<int>& nums) {
//    unordered_map<int, int> hashmap;
//    for (auto num : nums)
//    {
//        ++hashmap[num];
//    }
//    vector<int> ans;
//    for (const auto& [num, occ] : hashmap)
//    {
//        if (occ == 1)
//            ans.push_back(num);
//    }
//    return ans;
//}

int main()
{
	/*int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
	int n = sizeof(arr) / sizeof(arr[0]);
	vector<int> v(arr, arr +3);*/
    vector<int> v(10);
    v = { 1,0,2,3,0,4 };
    duplicateZeros(v);
	return 0;
}